package chapter14;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.File;
import java.io.IOException;

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/2/21 17:49
 */
public class HTMLTest {
    public static void main(String[] args) {
        Document document = null;
        try {
            document = Jsoup.parse(new File("D:\\article.html"), "UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        Elements elements = document.select("#cnblogs_post_body p a");
        for (Element e : elements) {
            String title = e.text();
            String href = e.attr("href");
            System.out.println(title + ", " + href);
        }
    }


}
